/**
 * @file	Module.cpp
 * @brief	Implement Module.
 *			Module is a class represents the cell modules.
 * @author	Shaokp
 * @date	2010-11-24
 * @version	0.1
 */

#include "Module.h"

#define PointNum 4

Module::Module(std::string name)
	:Element(name)
{
}

void Module::setPosition(Point &pos)
{
	mPos = pos;
}

Point Module::getPosition() const
{
	return mPos;
}

void Module::setSize(double sizex, double sizey)
{
	mSizeX = sizex;
	mSizeY = sizey;
}

void Module::getSize(double &sizex, double &sizey) const
{
	sizex = mSizeX;
	sizey = mSizeY;
}

void Module::setBufferExt(double bufferExt)
{
	mBufferExt = bufferExt;
}

double Module::getBufferExt() const
{
	return mBufferExt;
}

void Module::getVertexs(std::vector<Point> &vertexs, double buffer) const
{
	vertexs.clear();
	Point p;
	p.x = mPos.x - buffer;
	p.y = mPos.y - buffer;
	vertexs.push_back(p);
	p.y = mPos.y + mSizeY + buffer;
	vertexs.push_back(p);
	p.x = mPos.x + mSizeX + buffer;
	vertexs.push_back(p);
	p.y = mPos.y - buffer;
	vertexs.push_back(p);
}

void Module::setVertexs(std::vector<Point> &vertex)
{
	if(vertex.size() != 4)
		return;
	mPos = vertex[0];
	mSizeX = vertex[2].x - vertex[0].x;
	mSizeY = vertex[2].y - vertex[0].y;
}
